package mathExpEvaluator.model.operator;

public class OperatorPriority {
	private final int position;
	private final int bracketCount;
	private int priorityLevel;

	public OperatorPriority(int bc, int pl, int pos) {
		this.bracketCount = bc;
		this.priorityLevel = pl;
		this.position = pos;
	}

	public boolean isPriorTo(OperatorPriority p) {
		if (this.position == p.getPosition()) {
			throw new RuntimeException(
					"Two operators can't be in the same position!");
		}
		if (this.bracketCount > p.getBracketCount()) {
			return true;
		}
		if (this.bracketCount == p.bracketCount) {
			if (this.priorityLevel > p.getPriorityLevel()) {
				return true;
			}
			if (this.priorityLevel == p.getPriorityLevel()) {
				if (this.position < p.position) {
					return true;
				}
			}
		}
		return false;
	}

	public int getPosition() {
		return position;
	}

	public int getBracketCount() {
		return bracketCount;
	}

	public int getPriorityLevel() {
		return priorityLevel;
	}

	public void setPriorityLevel(int priorityLevel) {
		this.priorityLevel = priorityLevel;
		
	}
}
